#include "MntDisplayer.h"

#define DBG std::cout<<__FILE__<<":"<<__LINE__<<std::endl;

MntDisplayer::MntDisplayer(IFile* mn):Displayer(mn)
{

}


void MntDisplayer::display()
{
	//*
	glEnable(GL_TEXTURE_2D);
	
	glEnableClientState(GL_VERTEX_ARRAY);
	glEnableClientState(GL_INDEX_ARRAY); 
    long long int taille = _file->getNbFaces();
    
	glBindTexture(GL_TEXTURE_2D, _file->getTexID());

    glEnableClientState(GL_TEXTURE_COORD_ARRAY);
    glTexCoordPointer(2, GL_FLOAT, 0, _file->getTex());

	glVertexPointer(3, GL_FLOAT, 0, _file->getVertices());
	glDrawElements(GL_TRIANGLES, taille, GL_UNSIGNED_INT, _file->getFaces());

	glBindTexture(GL_TEXTURE_2D, 0);
}

MntDisplayer::~MntDisplayer()
{
	glDeleteBuffers(1, &_vbo);
}
